<template>
<!--套餐使用情况-->
<view class="community">
	<view class="head_bg"></view>
	<view class="big_box" style="margin-top:-160rpx;">
		<view v-if="info.is_over=='0'" class="package"  @tap="toTimeInfo(info)">
			<view class="flex">
				<view class="flex-sub">
					<view class="time_name text-white">{{info.package_name}}</view>
					<view class="text-white time_mon">¥<text>{{info.package_price}}</text></view>
				</view>
				<view class="flex-sub text-right">
					<view class="time_time text-white">{{info.begin_time.substring(0,10)}} 至 {{info.begin_time.substring(0,10)}}</view>
					<view class="time_add margin-top-xs time_add_color">{{info.residential_quarters_name}}</view>
					<view class="time_add time_add_color">仅限本小区使用</view>
				</view>
			</view>
			<view class="operating_box_inner">
				<view class="money_details_inner money_details_inner1">
					<view class="money_details_number time_add_color">{{info.charging_num}}</view>
					<view class="money_details_text time_add_color">总充电(次)</view>
				</view>
				<view class="detail_br" style="border-left: 1rpx solid #EDEDED;position: relative;top: 25rpx;"></view>
				<view class="money_details_inner money_details_inner1">
					<view class="money_details_number time_add_color">{{info.charging_time}}</view>
					<view class="money_details_text time_add_color">每次充电（小时）</view>
				</view>
				<view class="detail_br" style="border-left: 1rpx solid #EDEDED;position: relative;top: 25rpx;"></view>
				<view class="money_details_inner money_details_inner1">
					<view class="money_details_number time_add_color">{{info.surplus_num}}</view>
					<view class="money_details_text time_add_color">剩余（次）</view>
				</view>
			</view>
		</view>
		<view v-else class="package_gq">
			<view class="flex">
				<view class="flex-sub">
					<view class="time_name text-white">{{info.package_name}}</view>
					<view class="text-white time_mon">¥<text>{{info.package_price}}</text></view>
				</view>
				<view class="flex-sub text-right">
					<view class="time_time text-white ">已过期</view>
					<view class="time_add margin-top-xs text-white">{{info.residential_quarters_name}}</view>
					<view class="time_add text-white">仅限本小区使用</view>
				</view>
			</view>
			<view class="operating_box_inner">
				<view class="money_details_inner money_details_inner1">
					<view class="money_details_number time_add_color">{{info.charging_num}}</view>
					<view class="money_details_text time_add_color">总充电(次)</view>
				</view>
				<view class="detail_br" style="border-left: 1rpx solid #EDEDED;position: relative;top: 25rpx;"></view>
				<view class="money_details_inner money_details_inner1">
					<view class="money_details_number time_add_color">{{info.charging_time}}</view>
					<view class="money_details_text time_add_color">每次充电（小时）</view>
				</view>
				<view class="detail_br" style="border-left: 1rpx solid #EDEDED;position: relative;top: 25rpx;"></view>
				<view class="money_details_inner money_details_inner1">
					<view class="money_details_number time_add_color">{{info.surplus_num}}</view>
					<view class="money_details_text time_add_color">剩余（次）</view>
				</view>
			</view>
		</view>
		<view class="operating_box" v-for="(item,index) in list" :key="index">
			<view class="flex solid">
				<view class="flex-treble text-left margin-left-sm">
					<view class="text-black text-df padding-top-sm">
						终端编号：{{item.equipment_number}} 
						<span v-if="item.socket_port==0">1号口</span>
						<span v-else>2号口</span>
					</view>
					<view class="text-black text-df padding-top-sm padding-bottom-sm">
						充电时间：{{item.begin_time}} -- {{item.end_time}}
					</view>
				</view>
			</view>
		</view>
		<view v-if="list.length==0" class="margin-top-lg text-center">
			<image src='../../../common/img/no_data.png' style="width:275rpx;height:312rpx;"></image>
		</view>
		<!-- <view v-if="list.length>0" class="text-black text-df text-center bg-white padding-sm padding-left-lg be-gray">
			{{loadingTxt}} 共({{list.length}}条记录)
		</view> -->
	</view>
</view>
</template>

<script>
	let page=1,timer=null
	export default {
		data() {
			return {
				info:'',
				list:[],
				loadingTxt:'加载更多',
			}
		},
		onLoad(options) {
			this.info=JSON.parse(options.info)
		},
		onShow() {
			page=1;
			this.gatlist();
		},
		methods: {
			gatlist(){
				let that=this;
				that.http.tokenreq({
					url:"user/v1/setmealcharging",
					data:{"pageindex":page,"set_meal_guid":this.info.set_meal_guid}
				}).then((res) => {
					let e=res.data;
					if(e.code==0 && e.success){
						let list=e.data.rows;
						that.list=list;
						page++;
					}else{
						uni.showModal({
							content:e.message,
							showCancel:false,
						})
					}
				})
			},
			getmorelist(){
				this.loadingTxt='加载中'
				let that=this;
				that.http.tokenreq({
					url:"user/v1/setmealcharging",
					data:{"pageindex":page,"set_meal_guid":this.info.set_meal_guid}
				}).then((res) => {
					let e=res.data;
					if(e.code==0 && e.success){
						if(e.data.rows.length==0){
							that.loadingTxt="已经加载全部";
							return;
						}
						that.list=that.list.concat(e.data.rows);
						page++;
					}else{
						uni.showModal({
							content:e.message,
							showCancel:false,
						})
					}
				})
			},
			onReachBottom() {
				//阻止重复加载
				if(timer !== null){
					clearTimeout(timer)
				}
				timer=setTimeout(()=>this.getmorelist(),500)
			},
		}
	}
</script>
<style>
	.ele_title_inner{
		color: #FFFFFF;
		font-size:36rpx;
	}
	.package{
		background-image: url(../../../common/img/ka2.png);
		background-size: 100% 100%;
		width: 100%;
		height: 380rpx;
	}
	.time_name{
		padding: 20rpx 0 0rpx 40rpx;
		font-size: 34rpx;
	}
	.time_mon{
		padding: 0 0 0 40rpx;
		font-size: 50rpx;
	}
	.time_time{
		padding: 70rpx 30rpx 0 0rpx;
	}
	.time_add{
		padding: 0rpx 30rpx 0 0;
	}
	.time_add_color{
		color:#8C6B22
	}
	.operating_box{
		margin-top: 10rpx;
		padding-bottom: 0;
		border-radius: 20rpx;
	}
	.solid::after {
	    border: none;
	}
	.ele_title_inner{
		color: #FFFFFF;
		font-size:36rpx;
	}
	.package{
		background-image: url(../../../common/img/ka2.png);
		background-size: 100% 100%;
		width: 100%;
		height: 380rpx;
	}
	.package_gq{
		background-image: url(../../../common/img/ka3.png);
		width: 100%;
		background-size: 100% 100%;
		height: 380rpx;
	}
	.time_name{
		padding: 20rpx 0 0rpx 40rpx;
		font-size: 34rpx;
	}
	.time_mon{
		padding: 0 0 0 40rpx;
		font-size: 50rpx;
	}
	.time_time{
		padding: 57rpx 30rpx 0 0rpx;
	}
	.time_add{
		padding: 0rpx 30rpx 0 0;
	}
	.time_add_color{
		color:#8C6B22
	}
	.time_black{
		color: #666666 !important;
	}
	.money_details_inner{
		margin-top: 40rpx;
	}
</style>